//
// RTSPClientSession.h
//
// $Id: //base/include/RTSPClientSession.h
//
// Library: base
// Package: RTSP
// Module : RTSPClientSession
// Author :	Jelin,doitsjz@163.com
// Date	  :	10/30/2012
// 
// Definition of the RTSPClientSession class.
//
// Copyright (c) 2012-2012, iGuard.
//


#ifndef RTSPClientSession_INCLUDED
#define RTSPClientSession_INCLUDED

/**
	RTSPClientSession class for sending RTSP Request 
	and recving RTSP Response
*/
/*
A.1 Client State Machine

   The client can assume the following states:

   Init:
          SETUP has been sent, waiting for reply.

   Ready:
          SETUP reply received or PAUSE reply received while in Playing
          state.

   Playing:
          PLAY reply received

   Recording:
          RECORD reply received
state       message sent     next state after response
   Init        SETUP            Ready
               TEARDOWN         Init
   Ready       PLAY             Playing
               RECORD           Recording
               TEARDOWN         Init
               SETUP            Ready
   Playing     PAUSE            Ready
               TEARDOWN         Init
               PLAY             Playing
               SETUP            Playing (changed transport)
   Recording   PAUSE            Ready
               TEARDOWN         Init
               RECORD           Recording
               SETUP            Recording (changed transport)

*/
#include "base.h"
#include "RTSPSession.h"
using namespace std;

class BASE_API RTSPClientSession: public RTSPSession
{
public:
	RTSPClientSession(string &strURL);
	RTSPClientSession();
	~RTSPClientSession();
protected:
//	int handleMessage(RTSPMessage* pMessage);
	virtual int handleMessage(RTSPRequest& request);
	virtual int handleMessage(RTSPResponse& reply);

protected:
	//deal with reply from server,Client side,S->C
	void OnOptionsReply(int status,RTSPResponse& reply);
	void OnDescribeReply(int status,RTSPResponse& reply);
	void OnSetupReply(int status,RTSPResponse& reply);
	void OnPlayReply(int status,RTSPResponse& reply);
	void OnPauseReply(int status,RTSPResponse& reply);
	void OnRecordReply(int status,RTSPResponse& reply);
	void OnTeardownReply(int status,RTSPResponse& reply);
	//client side,S->C
	void OnRedirectRequest(){};

public:
	int makeDescribeRequest(string& req);
	int makeSetupRequest(int port,string& req);
	int makePlayRequest(float fStart,string& req);
	int makePauseRequest(string& req);
	int makeRecordRequest();
	int makeTeardownRequest(string& req);

	int makeRedirectReply();

protected:
	string m_strURL;

};

#endif